import request from '@/utils/request'

/**
 * 添加购物车
 * @param {*} query 
 * @returns 
 */
export const addCart = (query) => {
    return request({
        url: `/cart/${query.skuId}/${query.num}`,
        method: 'post'
    })
}

// 获取用户购物车列表
export const getUserCart = () => {
    return request({
        url: `/cart`,
        method: 'get'
    })
}

// 修改商品数量
export const updateCountItem = (query) => {
    return request({
        url: `/cart/countItem/${query.skuId}/${query.num}`,
        method: 'put'
    })
}

// 移除
export const removeItem = (query) => {
    return request({
        url: `/cart/${query.skuId}`,
        method: 'delete'
    })
}

// 选中商品项
export const selectCartProduct = (query) => {
    return request({
        url: `/cart/checkItem/${query.skuId}/${query.checked}`,
        method: 'put'
    })
}